use common_base::sqlx::mysql::MySqlArguments;

use crate::{db_manager::DbTool, ServiceContextBase};

pub struct DatasetUtil;

impl DatasetUtil {
    pub fn generate_sql_and_args(
        srv_ctx: &ServiceContextBase,
        table_name: &str,
        fields: &str,
        where_: &str,
        orderby: &str,
        arguments: MySqlArguments,
    ) -> (String, MySqlArguments) {
        let table_name = DbTool::get_dba_object(&srv_ctx.param_object, table_name);
        let sql = DbTool::select_sql(table_name.as_str(), fields, where_, orderby);
        (sql, arguments)
    }
}
